package com.a2v2.online.store.common.logger.contract;

import java.util.HashMap;
import java.util.Map;

public class LocalStorage {
	
	static final ThreadLocal<Map<String,String>> threadTicket = new ThreadLocal<Map<String,String>>();
	static final String USERID = "USERID";
	static final String TRXID = "TRXID";
	static final LocalStorage storage = new LocalStorage();
	
	private LocalStorage(){}
	
	public static LocalStorage getInstance(){
		return storage;
	}
	
	public void addUserID(String userID){
		Map<String,String> localMap = threadTicket.get();
		if (localMap==null){
			localMap = new HashMap<String,String>();
		}
		localMap.put(this.USERID, userID);
		threadTicket.set(localMap);
	}
	
	public void addTrxID(String TRXID) {
		Map<String,String> localMap = threadTicket.get();
		if (localMap==null){
			localMap = new HashMap<String,String>();
		}
		localMap.put(this.TRXID, TRXID);
		threadTicket.set(localMap);
		
	}
	
	public String getUserID(){
		Map<String,String> localMap = threadTicket.get();
		return localMap.get(USERID);
	}
	
	public String getTrxID(){
		Map<String,String> localMap = threadTicket.get();
		return localMap.get(this.TRXID);
	}
}

